package com.designMode.interpreter.terminal;

import com.designMode.interpreter.AbstractExpression;
import com.designMode.interpreter.Context;
import com.designMode.interpreter.TerminalExpression;

/**
 * 整型终结符
 */
public class MyInt extends TerminalExpression {
    private final int value;

    public MyInt(int value) {
        this.value = value;
    }

    @Override
    public Object interpret(Context ctx) {
        return value;
    }

    @Override
    public boolean equals(AbstractExpression exp) {
        if (exp != null && exp instanceof MyInt) {
            return this.value == ((MyInt) exp).value;
        }
        return false;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }
}
